package flst.ipiweb.proxy;

import java.util.List;

import flst.ipiweb.process.RelaisProcess;
import flst.ipiweb.transverse.IPIWebException;
import flst.ipiweb.transverse.Relais;

public class RelaisProxy {

	private RelaisProcess prel;
	private boolean droits = false;
	
	public RelaisProxy() {
		prel = new RelaisProcess();
	}

	public boolean getDroits() {
		return droits;
	}

	public void setDroits(boolean droits) {
		this.droits = droits;
	}
	
	public List<Relais> getAllRelais() throws IPIWebException{
		if(droits){
			return prel.getAllRelais();
		}
		else{
			return null;
		}
	}
	
	public Relais getRelaisById(int id) throws IPIWebException{
		if(droits){
			return prel.getRelaisById(id);
		}
		else{
			return null;
		}
	}
	
	public void createRelais(Relais rel) throws IPIWebException{
		if(droits){
			prel.CreateRelais(rel);
		}
	}
	
	public void updateRelais(Relais rel) throws IPIWebException{
		if(droits){
			prel.UpdateRelais(rel);
		}
	}
	
	public int generateId() throws IPIWebException{
		if(droits){
			return prel.GenerateId();
		}
		else{
			return -1;
		}
	}
	
	public void desactiverRelais(int id) throws IPIWebException{
		if(droits){
			prel.DesactiverRelais(id);
		}
	}
	
}
